﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using Xinkui.WebModel.Data;
using Xinkui.WebModel.Cache;
using Xinkui.WebModel;

public partial class UserControl_fore_UC_Catalog_Left : Xinkui.WebModel.BasicControl.ForeControl {

    public int SubLevel {
        get;
        set;
    }

    public int LeafLevel { get; set; }

    public string RootName { get; set; }

    public bool IsProducts { get; set; }

    protected void Page_Load(object sender, EventArgs e) {
        var query = SearchQueryData.Create();

        SubLevel = query.CategoryLevel2;
        LeafLevel = query.CategoryLevel3;

        var rootCategory = CategoryCache.ListAllCategory().FirstOrDefault(u => u.CategoryInfo.CategoryID == query.CategoryLevel1);

        if (rootCategory != null)
        {
            RootName = rootCategory.CategoryInfo.Title;
            rptLevel2.DataSource = rootCategory.SubViews;
            rptLevel2.DataBind();
        }
        else
        {
            this.Visible = false;
        }

    }

    protected string BindURL(object paths) {

        return IsProducts ? URLHelper.LinkToCatalogProducts(paths) : URLHelper.LinkToCatalogCompanys(paths);
    }
}